if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[x3blog_p_setUserInfo]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[x3blog_p_setUserInfo]
GO

create procedure [dbo].[x3blog_p_setUserInfo]
@user varchar(20),
@name nvarchar(16),
@email varchar(100)
as

SET NOCOUNT ON

IF(len(@email)>0)
BEGIN
	UPDATE [x3blog_t_user] SET nickname=@name,email=@email WHERE account=@user
END
ELSE
BEGIN
	UPDATE [x3blog_t_user] SET nickname=@name WHERE account=@user
END
SET NOCOUNT OFF

GO


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[x3blog_p_setUserPassword]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[x3blog_p_setUserPassword]
GO

create procedure [dbo].[x3blog_p_setUserPassword]
@user varchar(20),
@old char(40),
@pwd char(40)
as

UPDATE [x3blog_t_user] SET pwd=@pwd WHERE account=@user AND pwd=@old

GO


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[x3blog_p_forgetPassword]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[x3blog_p_forgetPassword]
GO

create procedure [dbo].[x3blog_p_forgetPassword]
@account varchar(20),
@answer char(40),
@pwd char(40),
@email varchar(100) output,
@name nvarchar(16) output
as

UPDATE [x3blog_t_user] SET @email=email,@name=nickname,pwd=@pwd WHERE account=@account AND answer=@answer

GO